package com.ea.admin.service.impl;

import com.ea.admin.mapper.AdminAccountMapper;
import com.ea.admin.pojo.po.AdminAccount;
import com.ea.common.result.BizException;
import com.ea.common.result.ErrorCode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CheckAccountService {
    @Resource
    AdminAccountMapper adminAccountMapper;

    public AdminAccount checkAdminAccount(Long accountId) {
        AdminAccount adminAccount = adminAccountMapper.selectById(accountId);
        if (adminAccount == null) {
            throw new BizException(ErrorCode.SYSTEM_RESOURCE_ADMIN_ACCOUNT_NOT_EXISTS);
        }
        if (adminAccount.getIsBlock() == 1) {
            throw new BizException(ErrorCode.USER_PARAM_ERROR_ACCOUNT_BLOCKED);
        }
        return adminAccount;
    }
}
